<template>

  <el-dialog title="题目审核" :visible.sync="isShow" width="36%" :before-close="handleClose">
      <el-radio v-model="chkdate.chkState" label="1">通过</el-radio>
  <el-radio v-model="chkdate.chkState" label="2">拒绝</el-radio>
  <p></p>
  <el-form :model="chkdate" :rules="rules" ref="ruleForm" >
 <el-form-item prop="chkRemarks">
    <el-input type="textarea" v-model="chkdate.chkRemarks"></el-input>
  </el-form-item>
 </el-form>

 <div slot="footer" class="dialog-footer">
    <el-button @click="handleClose">取 消</el-button>
    <el-button type="primary" @click='handleSub'>确 定</el-button>
  </div>
  </el-dialog>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'

export default {
  props: ['isShow', 'chkids'],
  data () {
    return {
      chkdate: {
        chkState: '1',
        chkRemarks: null
      },
      rules: {
        chkRemarks: [
          { required: true, message: '请填写活动形式', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {

    // 关闭弹窗
    handleClose () {
      this.$emit('update:isShow', false)
      this.$refs.ruleForm.resetFields()
      this.chkdate.chkState = '1'
    },

    // 提交
    handleSub () {
      console.log(this.chkdate.chkRemarks)
      this.$refs.ruleForm.validate(async (valid) => {
        if (valid) {
          try {
            await choiceCheck({
              chkState: Number(this.chkdate.chkState),
              chkRemarks: this.chkdate.chkRemarks,
              id: this.chkids
            })

            this.$parent.loadChoice()
            this.$refs.ruleForm.resetFields()
            this.chkdate.chkState = '1'
            this.$emit('update:isShow', false)
          } catch (error) {
            this.$message.error('审核失败')
          }
        } else {
          this.$message.error('审核失败')
          return false
        }
      })
    }

  }
}

</script>

<style scoped lang='less'></style>
